function Hash()
{
  this.length = 0;
  this.items = new Array();
  for (var i = 0; i < arguments.length; i += 2) {
    if (typeof(arguments[i + 1]) != 'undefined') {
      this.items[arguments[i]] = arguments[i + 1];
      this.length++;
    }
  }
  
  this.listItems = function()
  {
    for (var i in pageEditors.items) {
      alert(i + ' => ' + pageEditors.items[i]);
    }
  }
   
  this.removeItem = function(in_key)
  {
    var tmp_previous;
    if (typeof(this.items[in_key]) != 'undefined') {
      this.length--;
      var tmp_previous = this.items[in_key];
      delete this.items[in_key];
    }
     
    return tmp_previous;
  }

  this.getItem = function(in_key) {
    return this.items[in_key];
  }

  this.setItem = function(in_key, in_value)
  {
    var tmp_previous;
    if (typeof(in_value) != 'undefined') {
      if (typeof(this.items[in_key]) == 'undefined') {
        this.length++;
      }
      else {
        tmp_previous = this.items[in_key];
      }

      this.items[in_key] = in_value;
    }
     
    return tmp_previous;
  }

  this.hasItem = function(in_key)
  {
    return typeof(this.items[in_key]) != 'undefined';
  }

  this.clear = function()
  {
    for (var i in this.items) {
      delete this.items[i];
    }

    this.length = 0;
  }
}


YUI({ filter: 'debug' }).use("node", "io-base", "json-parse", 
   function(Y) {
    //Define a function to handle a successful response from
    //Wikipedia.  The success handler will find the response
    //object in its second argument:
    function successHandler(id, o){
      pageEditors = new Hash;
      Y.log("Success handler called; handler will parse the retrieved XML and insert into DOM.", "info", "example");
      Y.log("Success handler is complete.", "info", "example");
      oData = Y.JSON.parse(o.responseText);
      Y.log(oData.query.pages);
      for(var property in oData.query.pages) {
          pageID = property;
      }
      var revisions = oData.query.pages[property].revisions
      for (var i = 0; i < revisions.length; i++) {
        Y.log(revisions[i].user);
        if (pageEditors.hasItem(revisions[i].user)) {
          var numEdits = pageEditors.getItem(revisions[i].user);
          pageEditors.setItem(revisions[i].user, parseInt(numEdits) + 1);
        }
        else {             
          pageEditors.setItem(revisions[i].user, 1);
        }
      }
      var node = Y.one('#editsTable');
      for (var i in pageEditors.items) {
        node.append('<strong>'+i+'</strong> => ' + pageEditors.items[i] + '<br/>');
      }      
      //Y.log(pageID.revisions);
    }
 
    //Provide a function that can help debug failed
    //requests:
    function failureHandler(id, o){
        Y.log("Failure handler called; http status: " + o.status, "info", "example");
        //div.set("innerHTML", o.status + " " + o.statusText);
    }

    //When the Get RSS button is clicked, this function will fire
    //and compose/dispatch the IO request:
    function getModule(){
      //Create a querystring from the input value:
      var queryString = encodeURI('?action=query&format=json&prop=revisions&titles=Cat&rvlimit=100&rvprop=timestamp|user|comment');

      //The location of our server-side proxy:
      var entryPoint = 'proxy.cgi';

      //Compile the full URI for the request:
      var sUrl = entryPoint + queryString;

      var request = Y.io(sUrl, {
        method:"GET",
        on:
          {
            success:successHandler,
            failure:failureHandler
          }
        }
      );
    }
 
    //Use the Event Utility to wire the Get RSS button
    //to the getModule function:
    Y.on("click", getModule, "#pushButton"); 
});

